Section 3.6
Textures

The texture describes what the object looks like, i.e. its material. Textures are combinations of pigments, normals, finishes, and halos. Pigment is the color or pattern of colors inherent in the material. Normal is a method of simulating various patterns of bumps, dents, ripples or waves by modifying the surface normal vector. Finish describes the reflective and refractive properties of a material. Halo simulates effects like clouds, fog, fire etc. by using a density field defined inside the object.

A plain texture consists of a single pigment, an optional normal, a single finish and optionally one or more halos. A special texture combines two or more textures using a pattern or blending function. Special textures may be made quite complex by nesting patterns within patterns. At the innermost levels however, they are made up from plain textures. Note that allthough we call a plain texture "plain" it may be a very complex texture. The term "plain" only means that it has a single pigment, normal, finish and halo.

The most complete form for defining a plain texture is as follows:

texture { TEXTURE_IDENTIFIER pigment {...} normal {...} finish {...} halo {...} TRANSFORMATIONS }

Each of the items in a texture are optional but if they are present, the identifier must be first and the transformations must be last. The pigment, normal, and finish parameters modify any pigment, normal and finish already specified in the TEXTURE_IDENTIFIER. Any halos are added to the already existing halos. If no texture identifier is specified then the pigment, normal and finish statements modify the current default values and any halo is added to the default halo, if any. TRANSFORMATIONs are translate, rotate, scale and matrix statements. They should be specified last.

The sections below describe all of the options available in pigments, normals, finishes and halos. Special textures are covered later.


Section 3.6.1
Pigment

The color or pattern of colors for an object is defined by a pigment statement. All plain textures must have a pigment. If you do not specify one, the default pigment is used. A pigment statement is part of a texture specification. However it can be tedious to type "texture {pigment {...}}" just to add a color to an object. Therefore you may attach a pigment directly to an object without explicitly specifying that it as part of a texture. For example:

//this... //can be shortened to this... object { object { My_Object My_Object texture { pigment {color Red} pigment {color Red} } } }

The color you define is the way you want the object to look if fully illuminated. You pick the basic color inherent in the object and POV-Ray brightens or darkens it depending on the lighting in the scene. The parameter is called "pigment" because we are defining the basic color the object actually is rather than how it looks.

The most complete form for defining a pigment is as follows:

pigment { PIGMENT_IDENTIFIER PATTERN_TYPE PIGMENT_MODIFIERS... }

Each of the items in a pigment are optional but if they are present, they should be in the order shown above to insure that the results are as expected. Any items after the PIGMENT_IDENTIFIER modify or override settings given in the identifier. If no identifier is specified then the items modify the pigment values in the current default texture. Valid PIGMENT_MODIFIERS are color_map, pigment_map, image_map and quick_color statements as well as any of the generic PATTERN_MODIFIERS such as translate, rotate, scale, turbulence, wave shape and warp statements. Such modifiers apply only to the pigment and not to other parts of the texture. Modifiers should be specified last.

The various PATTERN_TYPEs fall into roughly 4 categories. Each category is discussed below. They are solid color, color list patterns, color mapped patterns and image maps.


Section 3.6.1.1
Solid Color Pigments

The simplest type of pigment is a solid color. To specify a solid color you simply put a color specification inside a pigment. For example:

pigment {color Orange}

A color specification consists of the option keyword color followed by a color identifier or by a specification of the amount of red, green, blue, filtered and unfiltered transparency in the surface. See section "Specifying Colors" for more details about colors. Any pattern modifiers used with a solid color are ignored because there is no pattern to modify.


Section 3.6.1.2
Color List Pigments

There are three color list patterns: checker, hexagon and brick. The result is a pattern of solid colors with distinct edges rather than a blending of colors as with color mapped patterns. Each of these patterns is covered in more detail in a later section. The syntax for each is:

pigment { brick COLOR1, COLOR2 MODIFIERS ... } pigment { checker COLOR1, COLOR2 MODIFIERS ... } pigment { hexagon COLOR1, COLOR2, COLOR3 MODIFIERS ... }

Each COLORn is any valid color specification. There should be a comma between each color or the color keyword should be used as a separator so that POV-Ray can determine where each color specification starts and ends.


Section 3.6.1.3
Color Maps

Most of the color patterns do not use abrupt color changes of just two or three colors like those in the brick, checker or hexagon patterns. They instead use smooth transitions of many colors that gradually change from one point to the next. The colors are defined in a pigment modifier called a color map that describes how the pattern blends from one color to the next.

Each of the various pattern types available is in fact a mathematical function that takes any x,y,z location and turns it into a number between 0.0 and 1.0 inclusive. That number is used to specify what mix of colors to use from the color map.

A color map is specified by...

pigment{ PATTERN_TYPE color_map { [ NUM_1 COLOR_1] [ NUM_2 COLOR_2] [ NUM_3 COLOR_3] ... } PIGMENT_MODIFIERS... }

Where NUM_1, NUM_2... are float values between 0.0 and 1.0 inclusive. COLOR_1, COLOR_2... are color specifications. NOTE: the [] brackets are part of the actual statement. They are not notational symbols denoting optional parts. The brackets surround each entry in the color map. There may be from 2 to 256 entries in the map. The alternate spelling colour_map may be used.

For example,

sphere { <0,1,2>, 2 pigment { gradient x //this is the PATTERN_TYPE color_map { [0.1 color Red] [0.3 color Yellow] [0.6 color Blue] [0.6 color Green] [0.8 color Cyan] } } }

The pattern function is evaluated and the result is a value from 0.0 to 1.0. If the value is less than the first entry (in this case 0.1) then the first color (Red) is used. Values from 0.1 to 0.3 use a blend of red and yellow using linear interpolation of the two colors. Similarly values from 0.3 to 0.6 blend from yellow to blue. Note that the 3rd and 4th entries both have values of 0.6. This causes an immediate abrupt shift of color from blue to green. Specifically a value that is less than 0.6 will be blue but exactly equal to 0.6 will be green. Moving along, values from 0.6 to 0.8 will be a blend of green and cyan. Finally any value greater than or equal to 0.8 will be cyan.

If you want areas of unchanging color you simply specify the same color for two adjacent entries. For example:

color_map { [0.1 color Red] [0.3 color Yellow] [0.6 color Yellow] [0.8 color Green] }

In this case any value from 0.3 to 0.6 will be pure yellow.

A color_map may be used with any pattern except brick, checker, hexagon and image_map.

You may declare and use color_map identifiers. For example:

#declare Rainbow_Colors= color_map { [0.0 color Magenta] [0.33 color Yellow] [0.67 color Cyan] [1.0 color Magenta] } object{My_Object pigment{ gradient x color_map{Rainbow_Colors} } }

Section 3.6.1.4
Pigment Maps

In addition to specifying blended color with a color_map, you may create a blend of pigments using a pigment_map. The syntax for a pigment_map is identical color_map except you specify a pigment in each map entry.

A pigment_map is specified by...

pigment{ PATTERN_TYPE pigment_map { [ NUM_1 PIGMENT_BODY_1] [ NUM_2 PIGMENT_BODY_2] [ NUM_3 PIGMENT_BODY_3] ... } PIGMENT_MODIFIERS... }

Where NUM_1, NUM_2... are float values between 0.0 and 1.0 inclusive. A PIGMENT_BODY is anything that would normally appear inside a pigment {...} statement but the pigment keyword and {} braces are not needed. NOTE: the [] brackets are part of the actual statement. They are not notational symbols denoting optional parts. The brackets surround each entry in the map. There may be from 2 to 256 entries in the map.

For example,

sphere { <0,1,2>, 2 pigment { gradient x //this is the PATTERN_TYPE pigment_map { [0.3 wood scale 0.2] [0.3 Jade] //this is a pigment identifier [0.6 Jade] [0.9 marble turbulence 1] } } }

When the gradient x function returns values from 0.0 to 0.3 the scaled wood pigment is used. From 0.3 to 0.6 the pigment identifier Jade is used. From 0.6 up to 0.9 a blend of Jade and a turbulent marble is used. From 0.9 on up only the turbulent marble is used.

Pigment maps may be nested to any level of complexity you desire. The pigments in a map may have color_map or pigment_maps or any type of pigment you want. Any entry of a pigment_map may be a solid color however if all entries are solid colors you should use a color_map which will render slightly faster.

Entire pigments may also be used with the block patterns such as checker, hexagon and brick. For example...

pigment { checker pigment { Jade scale .8 } pigment { White_Marble scale .5 } }

Note that in the case of block patterns, the pigment {...} wrapping is required around the pigment information.

A pigment_map is also used with the average pigment type. See "Average" for details.

You may not use pigment_map or individual pigments with an image_map. See "texture_map" for an alternative way to do this.


Section 3.6.1.5
Image Maps

When all else fails and none of the above pigment pattern types meets your needs, you can use an image map to wrap a 2-D bit-mapped image around your 3-D objects.

Section 3.6.1.5.1
Specifying an Image Map

The syntax for image_map is...

pigment { image_map { FILE_TYPE "filename" MODIFIERS... } }

Where FILE_TYPE is one of the following keywords gif, tga, iff, ppm, pgm, png, or sys. This is followed by the name of the file in quotes. Several optional modifiers may follow the file specification. The modifiers are described below. Note: Earlier versions of POV-Ray allowed some modifiers before the FILE_TYPE but that syntax is being phased out in favor of the syntax described here.

Filenames specified in the image_map statements will be searched for in the home (current) directory first, and if not found, will then be searched for in directories specified by any "-L" (library path) options active. This would facilitate keeping all your image maps files in a separate subdirectory, and giving an "-L" option on the command line to where your library of image maps are.

By default, the image is mapped onto the X-Y plane. The image is "projected" onto the object as though there were a slide projector somewhere in the -Z direction. The image exactly fills the square area from x,y coordinates (0,0) to (1,1) regardless of the image's original size in pixels. If you would like to change this default, you may translate, rotate or scale the pigment or texture to map it onto the object's surface as desired.

In the section "Checker" we explained checker pigment patterns, we described the checks as solid cubes of colored clay from which objects are carved. With image maps you should imagine that each pixel is a long, thin, square, colored rod that extends parallel to the Z axis. The image is made from rows and columns of these rods bundled together and the object is then carved from the bundle.

If you would like to change this default orientation, you may translate, rotate or scale the pigment or texture to map it onto the object's surface as desired.


Section 3.6.1.5.2
The map_type Option

The default projection of the image onto the X-Y plane is called a "planar map type". This option may be changed by adding the "map_type" keyword followed by a number specifying the way to wrap the image around the object.

A "map_type 0" gives the default planar mapping already described.

A "map_type 1" is a spherical mapping. It assumes that the object is a sphere of any size sitting at the origin. The Y axis is the north/south pole of the spherical mapping. The top and bottom edges of the image just touch the pole regardless of any scaling. The left edge of the image begins at the positive X axis and wraps the image around the sphere from "west" to "east" in a -Y rotation. The image covers the sphere exactly once. The "once" keyword has no meaning for this type.

With "map_type 2" you get a cylindrical mapping. It assumes that a cylinder of any diameter lies along the Y axis. The image wraps around the cylinder just like the spherical map but the image remains 1 unit tall from y=0 to y=1. This band of color is repeated at all heights unless the "once" keyword is applied.

Finally "map_type 5" is a torus or donut shaped mapping. It assumes that a torus of major radius 1 sits at the origin in the X-Z plane. The image is wrapped around similar to spherical or cylindrical maps. However the top and bottom edges of the map wrap over and under the torus where they meet each other on the inner rim.

Types 3 and 4 are still under development.

Note: The "map_type" option may also be applied to bump_map and material_map statements.


Section 3.6.1.5.3
The Filter and Transmit Bitmap Modifiers

To make all or part of an image map transparent, you can specify filter and/or transmit values for the color palette/registers of PNG, GIF or IFF pictures (at least for the modes that use palettes). You can do this by adding the keyword filter or transmit following the filename. The keyword is followed by two numbers. The first number is the palette number value and the second is the amount of transparency. The values should be separated by a comma. For example:

image_map { gif "mypic.gif" filter 0, 0.5 // Make color 0 50% filtered transparent filter 5, 1.0 // Make color 5 100% filtered transparent transmit 8, 0.3 // Make color 8 30% non-filtered transparent }

You can give the entire image a filter or transmit value using filter all VALUE or transmit all VALUE .

For example:

image_map { gif "stnglass.gif" filter all 0.9 }

Note: Early versions of POV-Ray used the keyword alpha to specify filtered transparency however that word is often used to descrbe non-filtered transparency. For this reason, alpha is no longer used.

See "filter" and "transmit" for details on the differences between filtered and non-filtered transparency.


Next Section
Table Of Contents